#!/bin/bash

# 定义变量方便修改
table_db=cy_database 
hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else 
	do_date=`date -d "-1 day" +%F`  
fi 

sql="
with
tmp_enterprise_person_info as (
	select
		id,
		identification,
		name,
		province_code,
		city_code,
		area_code,
		province,
		city,
		area,
		native_code,
		native_place,
		home_address,
		politics_code,
		politics,
		sex,
	    birthday,
		marital_status,
		education,
		school,
		ent_id,
		ent_name,
		industry_code,
		business_code,
		position_code,
		industry_type,
		business_type,
		position,
		phone,
		entry_work,
		out_work,
		work_year
	from cy_database.dwd_enterprise_person_info epi
	where epi.dt='2020-06-17' and epi.id is not null



)

insert overwrite table cy_database.dws_enterprise_person_info partition(dt='2020-06-17')
	select
		id,
		identification,
		name,
		province_code,
		city_code,
		area_code,
		province,
		city,
		area,
		native_code,
		native_place,
		home_address,
		politics_code,
		politics,
		sex,
		birthday,
		marital_status,
		education,
		school,
		ent_id,
		ent_name,
		industry_code,
		business_code,
		position_code,
		industry_type,
		business_type,
		position,
		phone,
		entry_work,
		out_work,
		work_year
	from tmp_enterprise_person_info

;



"
$hive -e "$sql"